package com.xkstream.client.nim;

import android.text.TextUtils;

import com.netease.nimlib.sdk.msg.attachment.MsgAttachment;

import org.json.JSONObject;

/**
 * Created by zhoujianghua on 2015/4/9.
 */
public abstract class CustomAttachment implements MsgAttachment {

    protected int type;

    public CustomAttachment(int type) {
        this.type = type;
    }

    public void fromJson(String str) {
        if (!TextUtils.isEmpty(str)) {
                parseData(str);
        }
    }

    @Override
    public String toJson(boolean send) {
        return CustomAttachParser.packData(type, packData());
    }

    public int getType() {
        return type;
    }

    public abstract void parseData(String str);
    public abstract JSONObject packData();
}
